package com.hzdl.sbdemo.controller;

import com.hzdl.sbdemo.bean.UserInfo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Controller
public class IndexController {

    @RequestMapping("indexInit")
    public String indexInit(Model model){
        model.addAttribute("name","你好");

        UserInfo userInfo = new UserInfo(1001,"ww");
        userInfo.setAge(18);
        userInfo.setBirth(new Date());
        userInfo.setPwd("123456");
        model.addAttribute("student",userInfo);

        UserInfo userInfo2 = new UserInfo(1002,"aa");
        UserInfo userInfo3 = new UserInfo(1003,"qq");

        List<UserInfo> list = new ArrayList<>();
        list.add(userInfo);
        list.add(userInfo2);
        list.add(userInfo3);

        model.addAttribute("uList",list);
        return "index";
    }

    @RequestMapping("/index/login")
    public String login (UserInfo student){
        System.out.println(student);
        return "user";
    }
}
